using System.Reflection.Emit;

namespace TSharp.Core.Emit
{
    /// <summary>
    /// ForState
    /// </summary>
    internal class ForState
    {
        /// <summary>
        /// The begin label
        /// </summary>
        private readonly Label beginLabel;
        /// <summary>
        /// The end
        /// </summary>
        private readonly object end;
        /// <summary>
        /// The index variable
        /// </summary>
        private readonly LocalBuilder indexVariable;
        /// <summary>
        /// The test label
        /// </summary>
        private readonly Label testLabel;

        /// <summary>
        /// Initializes a new instance of the <see cref="ForState"/> class.
        /// </summary>
        /// <param name="indexVariable">The index variable.</param>
        /// <param name="beginLabel">The begin label.</param>
        /// <param name="testLabel">The test label.</param>
        /// <param name="end">The end.</param>
        public ForState(LocalBuilder indexVariable, Label beginLabel, Label testLabel, object end)
        {
            this.indexVariable = indexVariable;
            this.beginLabel = beginLabel;
            this.testLabel = testLabel;
            this.end = end;
        }

        /// <summary>
        /// Gets the begin label.
        /// </summary>
        /// <value>The begin label.</value>
        public Label BeginLabel
        {
            get { return beginLabel; }
        }

        /// <summary>
        /// Gets the end.
        /// </summary>
        /// <value>The end.</value>
        public object End
        {
            get { return end; }
        }

        /// <summary>
        /// Gets or sets the end label.
        /// </summary>
        /// <value>The end label.</value>
        public Label EndLabel { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether [requires end label].
        /// </summary>
        /// <value><c>true</c> if [requires end label]; otherwise, <c>false</c>.</value>
        public bool RequiresEndLabel { get; set; }

        /// <summary>
        /// Gets the index variable.
        /// </summary>
        /// <value>The index variable.</value>
        public LocalBuilder IndexVariable
        {
            get { return indexVariable; }
        }

        /// <summary>
        /// Gets the test label.
        /// </summary>
        /// <value>The test label.</value>
        public Label TestLabel
        {
            get { return testLabel; }
        }
    }
}